ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
MailScheduler.h
Go to the documentation of this file.
00001 
00018 #ifndef SCHEDULER_H_
00019 #define SCHEDULER_H_
00020 /*
00021  **************************************************************
00022  * Defines, Macros and Typedefs 
00023  **************************************************************/
00024 /*** Constant Macros ***/
00025 /* Default Yes and No defines */
00026 #ifndef TRUE
00027 #define TRUE (1u)
00028 #endif
00029 #ifndef CLEAR
00030 #define CLEAR (0u)
00031 #endif
00032 #ifndef BITS_IN_NIBBLE
00033 #define BITS_IN_NIBBLE (4u)
00034 #endif
00035 #ifndef BITS_IN_BYTE
00036 #define BITS_IN_BYTE (8u)
00037 #endif
00038 #ifndef BITS_IN_32
00039 #define BITS_IN_32  (32u)
00040 #endif
00041 #ifndef BITS_IN_16
00042 #define BITS_IN_16  (16u)
00043 #endif
00044 #ifndef BYTES_IN_32
00045 #define BYTES_IN_32  (4u)
00046 #endif
00047 #ifndef BYTES_IN_16
00048 #define BYTES_IN_16  (2u)
00049 #endif
00050 
00051 #define SCHED_TRIGGER_TX_ISR        (0u)
00052 #define SCHED_INBOX_DONE_SW_ISR_1  (0u)
00053 #define SCHED_INBOX_DONE_SW_ISR_2  (1)
00054 #define SCHED_INBOX_DONE_SW_ISR_3  (2u)
00055 #define SCHED_INBOX_DONE_SW_ISR_4  (3u)
00056 #define SCHED_RESCHED_1  (5u)
00057 #define SCHED_RESCHED_2  (6u)
00058 #define SCHED_RESCHED_3  (7u)
00059 
00060 /* Masks for rescheduling */
00061 #define RESCH_SRC_1 BIT0
00062 #define RESCH_SRC_2 BIT1
00063 #define RESCH_SRC_3 BIT2
00064 /*** Function Macros ***/
00065 #define SCHED_WHAT_IS_THE_TIME(XX)          XX = gu32SchedTickCount
00066 #define SCHED_WHEN_WAS_THE_LAST_TX_DONE(XX) XX = gu32SchedTxDoneCount
00067 
00068 #ifndef CLEAR_ISR_FLAG
00069 #define CLEAR_ISR_FLAG(XX)       INTC.SSCIR[XX].B.CLR = TRUE
00070 #endif
00071 /*** Enums ***/
00072 
00073 /*** TypeDefs ***/
00074 
00075 /*
00076  **************************************************************
00077  * Declarations 
00078  **************************************************************/
00079 /*** Constants ***/
00080 
00081 /*** Globals ***/
00082 extern vuint32_t gu32SchedTickCount;
00083 extern vuint32_t gu32SchedTxDoneCount;
00084 extern vuint8_t gu8RescheduleSource;
00085 extern uint8_t gu8ReSchPITCh;
00086 /*
00087  **************************************************************
00088  * Function Prototypes 
00089  **************************************************************/
00090 /*
00091  ******************************************************************************
00092  *
00093  * Function:          u8fnSchedConfig()
00094  *
00095  */
00110 uint8_t u8fnSchedConfig(uint32_t u32PITCnt, uint8_t u8PITCh, 
00111                         uint32_t u32ReSchCnt, uint8_t u8ReSchPITCh);
00112 /*
00113  ******************************************************************************
00114  *
00115  * Function:          u8fnSchedEnable()
00116  *
00117  */
00124 uint8_t u8fnSchedEnable(uint8_t u8Enable);
00125 /*
00126  ******************************************************************************
00127  *
00128  * Function:          u8fnSchedDSPIMailTransfer()
00129  *
00130  */
00144 uint8_t u8fnSchedDSPIMailTransfer(uint8_t u8DSPIInstance, uint8_t u8CS,
00145                                   uint8_t u8ContCS, uint8_t u8EndOfQueueFlag,
00146                                   uint16_t* pu16MsgSrc,
00147                                   uint16_t* pu16MsgResponse, uint16_t u16Size);
00148 /*
00149  ******************************************************************************
00150  *
00151  * Function:          u8fnSchedCompositeDSPIMailTransfer()
00152  *
00153  */
00173 uint8_t u8fnSchedCompositeDSPIMailTransfer(const uint8_t u8DSPIInstance1,
00174                                            const uint8_t u8DSPIInstance2,
00175                                            const uint8_t u8CS,
00176                                            uint16_t* pu16MsgSrc1,
00177                                            uint16_t* pu16MsgSrc2,
00178                                            const uint16_t* pu16MsgResponse,
00179                                            uint16_t u16SizeAtOrigin);
00180 /*
00181  ******************************************************************************
00182  *
00183  * Function:          u32fnSchedHasTimeElapsed()
00184  *
00185  */
00193 uint32_t u32fnSchedHasTimeElapsed(uint32_t u32MyTickCount);
00194 /*
00195  ******************************************************************************
00196  *
00197  * Function:          u32fnSchedIsTxDone()
00198  *
00199  */
00207 uint32_t u32fnSchedIsTxDone(uint32_t u32MyTickCount);
00208 /*
00209  ******************************************************************************
00210  *
00211  * Function:          vfnSchedIsr()
00212  *
00213  */
00220 void vfnSchedIsr(void);
00221 /*
00222  ******************************************************************************
00223  *
00224  * Function:          vfnSchedInboxDoneIsr()
00225  *
00226  */
00234 void vfnSchedInboxDoneIsr(void);
00235 /*
00236  ******************************************************************************
00237  *
00238  * Function:          vfnReschedulerIsr()
00239  *
00240  */
00249 void vfnReschedulerIsr(void);
00250 
00251 #endif /* SCHEDULER_H_ */